package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsFeedbackMapper;
import com.qf.pojo.DtsAccountTrace;
import com.qf.pojo.DtsFeedback;
import com.qf.service.DtsAdminFeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * @author YDW
 * projectName:shop-manage
 * time:2022/5/24 13:14
 * description:
 */
@Service
public class DtsAdminFeedbackServiceImpl implements DtsAdminFeedbackService {

    @Autowired
    DtsFeedbackMapper feedbackMapper;
    @Override
    public IPage<DtsFeedback> queryPage(Integer page, Integer limit, String sort, String order, Integer id, String username) {
        IPage<DtsFeedback> ipage=new Page<>(page,limit);
        QueryWrapper qw=new QueryWrapper<>();
        qw.eq("deleted",false);
        if(id!=null){
            qw.like("id",id);
        }
        if(!StringUtils.isEmpty(username)){
            qw.like("username",username);
        }

        if(!StringUtils.isEmpty(sort)&&!StringUtils.isEmpty(order)){
            if(order.equals("desc")){
                qw.orderByDesc(sort);
            }else {
                qw.orderByAsc(sort);
            }
        }
        feedbackMapper.selectPage(ipage, qw);
        return ipage;
    }
}
